var bookData = [
	{ value: 1020, name: '线装古籍' },
	{ value: 481, name: '民国旧书' },
	{ value: 238, name: '名人墨迹' },
	{ value: 636, name: '名人字画' },
	{ value: 161, name: '期刊' },
	{ value: 119, name: '报纸' },
	{ value: 333, name: '外文古旧书' },
	{ value: 643, name: '小说' },
	{ value: 3137, name: '文学' },
	{ value: 198, name: '语言文字' },
	{ value: 720, name: '历史' },
	{ value: 15, name: '地理' },
	{ value: 827, name: '艺术' },
	{ value: 28, name: '政治' },
	{ value: 31, name: '法律' },
	{ value: 28, name: '军事' },
	{ value: 77, name: '哲学心理学' },
	{ value: 44, name: '宗教' },
	{ value: 50, name: '经济' },
	{ value: 692, name: '社会文化' },
	{ value: 200, name: '教育' },
	{ value: 51, name: '管理' },
	{ value: 173, name: '童书' },
	{ value: 51, name: '生活' },
	{ value: 43, name: '体育' },
	{ value: 95, name: '工程技术' },
	{ value: 34, name: '计算机与互联网' },
	{ value: 50, name: '自然科学' },
	{ value: 316, name: '医药卫生' },
	{ value: 7286, name: '综合性图书' },
	{ value: 555, name: '国学古籍' },
	{ value: 125, name: '收藏与鉴赏' },
	{ value: 224, name: '红色文献' },
	{ value: 618, name: '教材教辅考试' },
	{ value: 14, name: '古旧地图' },
	{ value: 63, name: '照片影像' },
	{ value: 302, name: '连环画' },
	{ value: 47, name: '版画宣传画' },
	{ value: 75, name: '邮票税票' },
	{ value: 62, name: '钱币' },
	{ value: 77, name: '碑帖' },
	{ value: 0, name: '印谱' }, 
	{ value: 51, name: '红色收藏' },
	{ value: 50, name: '文房雅玩' },
	{ value: 121, name: '玉石金银木器' },
	{ value: 2, name: '漆器' },
	{ value: 105, name: '陶器瓷器' },
	{ value: 16, name: '工艺品' },
	{ value: 769, name: '收藏杂项' },
	{ value: 4, name: '笔墨' },
	{ value: 15, name: '纸本' },
	{ value: 7, name: '卡片' },
	{ value: 2, name: '日历' },
	{ value: 0, name: '包袋' }, 
	{ value: 0, name: '壳套' },
	{ value: 4, name: '摆件挂画' },
	{ value: 2, name: '器皿' },
	{ value: 45, name: '动漫影视周边' }
];
var sortedBookData = bookData.slice().sort(function(a, b) {
	return b.value - a.value;
}).slice(0, 5);	
var left1 =echarts.init(document.getElementById("left1"),'infographic');
var left2 =echarts.init(document.getElementById("left2"),'infographic');
var left3 =echarts.init(document.getElementById("left3"),'infographic');
var option1 = {
	title: {
		text: '主要商品种类',
		subtext: '来自：分类排行榜',
		left: 'center'
	},
	toolbox: {
		feature: {
			saveAsImage: {}, 
			dataView: { readOnly: false }, 
			restore: {}, 
		}
	},
	tooltip: {
		trigger: 'item'
	},
	legend: {
		orient: 'vertical',
		left: 'left'
	},
	series: [
		{
			name: '销量',
			type: 'pie',
			radius: '50%',
			data: sortedBookData,
			emphasis: {
				itemStyle: {
					shadowBlur: 10,
					shadowOffsetX: 0,
					shadowColor: 'rgba(0, 0, 0, 0.5)'
				}
			}
		}
	]
};
var option2 = {
    title: {
        text: '《红楼梦》2024上半年销量变化图',
        left: 'left'
    },
	toolbox: {
		feature: {
			saveAsImage: {}, 
			dataView: { readOnly: false }, 
			magicType: { type: ['line', 'bar'] },
			restore: {}, 
			dataZoom: { yAxisIndex: null } 
		}
	},
    tooltip: {
        trigger: 'axis'
    },
    legend: {
        data: ['销量'],
		show:false
    },
    xAxis: {
        type: 'category',
        boundaryGap: false,
        data: ['2023-01', '2023-02', '2023-03', '2023-04', '2023-05', '2023-06']
    },
    yAxis: {
        type: 'value',
        name: '销量（本）',
        nameTextStyle: {
            align: 'left'
        }
    },
    series: [
        {
            name: '销量',
            type: 'line',
            stack: '总量',
            data: [120, 132, 101, 134, 90, 230]
        }
    ],

};
var option3 = {
  title: {
    text: '新书与二手书的对比'
  },
  legend: {
    data: ['新书', '二手书'],
    left: '10%', 
    bottom: '10%', 
    orient: 'vertical'
  },
  toolbox: {
  	feature: {
  		saveAsImage: {}, 
  		dataView: { readOnly: false }, 
  		restore: {}, 
  	}
  },
  radar: {
    indicator: [
      { name: '价格', max: 100 }, 
      { name: '销量', max: 100 }, 
      { name: '评价', max: 100 },
      { name: '库存量', max: 100 },
    ]
  },
  series: [
    {
      name: '新书与二手书',
      type: 'radar',
      data: [
        {
          value: [80, 70, 80,60], 
          name: '新书'
        },
        {
          value: [40, 30,65,88],
          name: '二手书'
        }
      ]
    }
  ]
};


left1.setOption(option1);
left2.setOption(option2);
left3.setOption(option3);

left1.on('click', function (params) {
    window.location.href = 'https://shop.kongfz.com/ranklist/?event=cat&type=8000000000000000&provId=5000000000&cityId=0&currPage=1';
});
left2.on('click', function (params) {
    window.location.href = 'https://item.kongfz.com/book/51144142.html';
});